<ui:composition xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:a4j="http://richfaces.org/a4j"
  xmlns:zanata="http://java.sun.com/jsf/composite/zanata"
  template="/WEB-INF/template/template_nobanner.xhtml">

  <ui:define name="page_title">#{msgs['jsf.ResetPassword']}</ui:define>
  <ui:define name="center_content">
    <div class="header__logo-only">
      <h:link outcome="/public/home.xhtml" id="home" tabindex="1">
        <img src="#{request.contextPath}/resources/assets/img/logo/logo.svg" alt="Zanata"/>
      </h:link>
    </div>
    <div class="g--centered">
      <div class="g__item l--constrain-small">
        <div class="l--push-v-1">
          <h2 class="gamma heading--sub">#{msgs['jsf.ResetPassword']}</h2>

          <h:form id="passwordResetRequestForm">
            <a4j:outputPanel ajaxRendered="true" layout="block" id="messages">
              <h:messages globalOnly="true"
                styleClass="list--no-bullets"
                errorClass="message--danger app-error l--push-bottom-half"
                infoClass="message--highlight l--push-bottom-half"
                warnClass="message--warning l--push-bottom-half"
                rendered="#{showGlobalMessages != 'false'}"/>
            </a4j:outputPanel>

            <div class="l--push-top-half l--pad-all-1 bg--pop-higher">
              <a4j:jsFunction name="sendActivationEmail"
                action="#{passwordResetRequest.sendActivationEmail(usernameOrEmail)}"
                limitRender="true">
                <a4j:param name="val1" assignTo="#{usernameOrEmail}"/>
              </a4j:jsFunction>

              <h:panelGroup layout="block"  id="actions">
                <ui:fragment rendered="#{passwordResetRequest.accountWaitingForActivation}">
                  <div class="l--push-top-half">
                    <a href="#" onclick="sendActivationEmail('#{passwordResetRequest.usernameOrEmail}')"
                      class="loader">
                      <span class="loader__label">#{msgs['jsf.ResendActivationEmail']}</span>
                    </a>
                  </div>
                </ui:fragment>
              </h:panelGroup>

              <zanata:decorate id="usernameEmail" componentId="usernameEmailField">
                <h:outputLabel for="usernameEmail">#{msgs['jsf.UsernameOrEmail.placeholder']}</h:outputLabel>
                <h:inputText id="usernameEmail" required="true" placeholder="#{msgs['jsf.UsernameOrEmail.placeholder']}"
                  value="#{passwordResetRequest.usernameOrEmail}" maxlength="260">
                  <a4j:ajax event="blur" render="usernameEmailField"/>
                </h:inputText>
              </zanata:decorate>
              <a4j:commandButton styleClass="l--push-top-1 button--primary button--full"
                value="#{msgs['jsf.ResetPassword']}" render="actions"
                action="#{passwordResetRequest.requestReset}" id="submitRequest"/>
            </div>
          </h:form>
        </div>
      </div>
    </div>
  </ui:define>
</ui:composition>
